**Daxecker and Prins, International Interactions conditional acceptance repdate do*

tsset cowcode year

*TABLE 1*
*Model 1, without selection*
reg ln_imbmediandistancekm l.goveffectby10 somalia lnlandarea l.lngdpcap coast_ln , robust 
est store dist1

*Model 2, with selection*
heckman ln_imbmediandistancekm l.goveffectby10 somalia lnlandarea l.lngdpcap coast_ln    , select(piracy_dum_imb =   l.goveffectby10 somalia lnlandarea l.lngdpcap  l.lnpop coast_ln  pirpeaceyrs imb_spline1 imb_spline2 imb_spline3) robust
est store dist2

*Model 3, Incidents in ports only*
heckman ln_imbmedportdistancekm l.goveffectby10 somalia lnlandarea l.lngdpcap coast_ln   , select(imbpiracyportdum =   l.goveffectby10 somalia lnlandarea l.lngdpcap  l.lnpop coast_ln portpirpeaceyrs imbport_spline1 imbport_spline2 imbport_spline3) robust
est store dist3

*Model 4, Controlling for proximity of capital to coast*
 heckman ln_imbmediandistancekm c.l.goveffectby10##i.coastcapital somalia lnlandarea l.lngdpcap coast_ln   , select(piracy_dum_imb =   l.goveffectby10 somalia lnlandarea l.lngdpcap  l.lnpop coast_ln  pirpeaceyrs imb_spline1 imb_spline2 imb_spline3) robust
est store dist4

*Model 5, Using Asam data*
heckman lnmeddistasam_1  l.goveffectby10 somalia lnlandarea l.lngdpcap coast_ln  , select(piracydum_asam=   l.goveffectby10 l.lngdpcap  somalia lnlandarea l.lnpop coast_ln  peaceyrsasam asamspline1 asamspline2 asamspline3) robust
est store dist5

*Model 6, Other state capacity measure*
heckman ln_imbmediandistancekm l.sfi somalia lnlandarea l.lngdpcap coast_ln  , select(piracy_dum_imb =   l.sfi l.lngdpcap somalia lnlandarea  l.lnpop coast_ln  pirpeaceyrs imb_spline1 imb_spline2 imb_spline3) robust
est store dist6

*Model 7, Mean Distances*
heckman ln_imbmeandistancekm l.goveffectby10 somalia lnlandarea l.lngdpcap coast_ln   , select(piracy_dum_imb =   l.goveffectby10 somalia lnlandarea l.lngdpcap  l.lnpop coast_ln  pirpeaceyrs imb_spline1 imb_spline2 imb_spline3) robust
est store dist7

*Model 8, Excluding Somalia dummy*
heckman ln_imbmediandistancekm l.goveffectby10  lnlandarea l.lngdpcap coast_ln    , select(piracy_dum_imb =   l.goveffectby10   lnlandarea l.lngdpcap  l.lnpop coast_ln  pirpeaceyrs imb_spline1 imb_spline2 imb_spline3) robust
est store dist8

*Model 9, Two stage model from Vance and Ritter JPR 2014 51(4)*
/*First estimate the probit model and store the results as 'x'.*/
probit piracy_dum_imb   l.goveffectby10 somalia lnlandarea l.lngdpcap  l.lnpop coast_ln  pirpeaceyrs imb_spline1 imb_spline2 imb_spline3
est store x
/*Now estimate the OLS model and store the results as 'z'.*/              
reg ln_imbmediandistancekm l.goveffectby10 somalia lnlandarea coast_ln l.lngdpcap 
estimates store z
/*Now estimate the two modeles jointly using 'seemingly unrelated regression'. The table produced by this will give the raw coefficient estimates, which are presented in Table 1.*/
suest x z, robust
est store dist9

*FIGURE 1*

*(1) Plotting marginal effects across all values of government effectiveness*
*Model with government effectiveness*
heckman ln_imbmediandistancekm l.goveffect somalia lnlandarea l.lngdpcap coast_ln  , select(piracy_dum_imb =   l.goveffect somalia lnlandarea l.lngdpcap  l.lnpop coast_ln  pirpeaceyrs imb_spline1 imb_spline2 imb_spline3) robust
margins,  atmeans at(l.goveffect =(0(5)100) ) vsquish
marginsplot, recast(line) plot1opts(lpattern(-)) recastci(rline)  ciopts(color(gs13))  title("") legend(off) addplot(kdensity goveffect, yaxis(2) yscale(alt axis(2))) saving(govmargins1, replace)

*FIGURE 2*
*(2) Marginal effects plots of key IVs and significant variables*

*Model 1 without selection*
reg ln_imbmediandistancekm l.goveffectby10 somalia lnlandarea l.lngdpcap coast_ln , robust 
margins, dydx(l.goveffectby10  lnlandarea l.lngdpcap coast_ln) atmeans post
est store marg1

*Model 2, with selection*
heckman ln_imbmediandistancekm l.goveffectby10 somalia lnlandarea l.lngdpcap coast_ln    , select(piracy_dum_imb =   l.goveffectby10 somalia lnlandarea l.lngdpcap  l.lnpop coast_ln  pirpeaceyrs imb_spline1 imb_spline2 imb_spline3) robust
margins, dydx(l.goveffectby10  lnlandarea  l.lngdpcap coast_ln) atmeans  post
est store marg2

*Model 3, Incidents in ports only*
heckman ln_imbmeandistancekm l.goveffectby10 somalia lnlandarea l.lngdpcap coast_ln   , select(piracy_dum_imb =   l.goveffectby10 somalia lnlandarea l.lngdpcap  l.lnpop coast_ln  pirpeaceyrs imb_spline1 imb_spline2 imb_spline3) robust
margins, dydx(l.goveffectby10  lnlandarea  l.lngdpcap coast_ln) atmeans post
est store marg3

*Model 4, Controlling for proximity of capital to coast*
 heckman ln_imbmediandistancekm c.l.goveffectby10##i.coastcapital somalia lnlandarea l.lngdpcap coast_ln   , select(piracy_dum_imb =   l.goveffectby10 somalia lnlandarea l.lngdpcap  l.lnpop coast_ln  pirpeaceyrs imb_spline1 imb_spline2 imb_spline3) robust
margins, dydx(c.l.goveffectby10   lnlandarea l.lngdpcap coast_ln) atmeans post
est store marg4

*Model 5, Using Asam data*
heckman lnmeddistasam  l.goveffectby10 somalia lnlandarea l.lngdpcap coast_ln  , select(piracydum_asam=   l.goveffectby10 l.lngdpcap  somalia lnlandarea l.lnpop coast_ln  peaceyrsasam asamspline1 asamspline2 asamspline3) robust
margins, dydx(l.goveffectby10  lnlandarea l.lngdpcap coast_ln) atmeans post
est store marg5

*Model 6, Other state capacity measure*
heckman ln_imbmediandistancekm l.sfi somalia lnlandarea l.lngdpcap coast_ln  , select(piracy_dum_imb =   l.sfi l.lngdpcap somalia lnlandarea  l.lnpop coast_ln  pirpeaceyrs imb_spline1 imb_spline2 imb_spline3) robust
margins, dydx(l.sfi  lnlandarea l.lngdpcap coast_ln) atmeans post
est store marg6

*create figure with significant variables in models 1-6*
coefplot (marg1, lab(Model 1)) (marg2, lab(Model 2)) (marg3, lab(Model 3)) (marg4, lab(Model 5)) (marg5, lab(Model 5)) (marg6, lab(Model 6)),  xline(0, lpattern(_) ) level(90) legend(pos(4))  ciopts(recast(rcap)) saving(model1-6margins, replace)

*Table A1: Descriptives*
heckman ln_imbmediandistancekm l.goveffectby10 i.somalia lnlandarea  l.lngdpcap  , select(piracy_dum_imb=   l.goveffectby10 l.lngdpcap  l.lnpop coast_ln  pirpeaceyrs imb_spline1 imb_spline2 imb_spline3) robust
estpost sum ln_imbmediandistancekm  goveffectby10 somalia lnlandarea  lngdpcap  lnpop coast_ln  pirpeaceyrs if e(sample)
esttab using myfilesum1.rtf, cell("mean (fmt(3)) sd (fmt(3)) min (fmt(3)) max (fmt(3))") star rtf label replace
heckman ln_imbmeandistancekm l.goveffectby10 i.somalia lnlandarea  l.lngdpcap  , select(piracy_dum_imb=   l.goveffectby10 l.lngdpcap  l.lnpop coast_ln  pirpeaceyrs imb_spline1 imb_spline2 imb_spline3) robust
estpost sum ln_imbmeandistancekm goveffectby10 somalia lnlandarea  lngdpcap  lnpop coast_ln  pirpeaceyrs if e(sample)
esttab using myfilesum1.rtf, cell("mean (fmt(3)) sd (fmt(3)) min (fmt(3)) max (fmt(3))") star rtf label replace
